using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Blople.GameScenes
{
    public class GameScene : Microsoft.Xna.Framework.DrawableGameComponent
    {
        protected List<GameComponent> components;

        public GameScene(Game game) : base(game)
        {
            components = new List<GameComponent>();
            Visible = false;
            Enabled = false;
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            // update all actors

            for (int i = 0; i < components.Count; i++)
            {
                if (components[i].Enabled)
                {
                    components[i].Update(gameTime);
                }
            }

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            // draw actors if DrawableGameComponent

            for (int i = 0; i < components.Count; i++)
            {
                if ((components[i] is DrawableGameComponent) && ((DrawableGameComponent)components[i]).Visible)
                {
                    ((DrawableGameComponent)
                        components[i]).Draw(gameTime);
                }
            }

            base.Draw(gameTime);
        }

        public virtual void Show()
        {
            Visible = true;
            Enabled = true;
        }

        public virtual void Hide()
        {
            Visible = false;
            Enabled = false;
        }
    }
}
